package functionInterface;

import java.util.function.Function;

public class FunctionTest {

    /**
     * 测试Function的两个默认方法
     * @param args
     */
    public static void main(String[] args) {

        Function<Integer, Integer> f1 = x -> x + 1;
        Function<Integer, Integer> f2 = x -> x * 2;

        Function<Integer, Integer> f3 = f1.andThen(f2);
        Function<Integer, Integer> f4 = f1.compose(f2);

        System.out.println(f3.apply(1));
        System.out.println(f4.apply(1));

        System.out.println(f3.apply(2));
        System.out.println(f4.apply(2));

        System.out.println(f3.apply(3));
        System.out.println(f4.apply(3));
    }
}
